home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-02-15 | 22.6 KB | 718 lines | [TEXT/MPS ] |
- ;_________________________________________________________________________________
- ;
- ; File: XTIShell.a
- ;
- ; This file contains code that implements calls from AURP to the adev. Once
- ; the call is determined, a routine in C is usually called to perform the guts
- ; of the call (with a few exceptions). These C routines can be found in XTIShell.c.
- ; Hints on things that may need to be change are provided throughtout.
- ;
- ; Apple Computer, Inc.
- ; Copyright (C) 1992,1993. All rights reserved.
- ;
- ; Revision History:
- ;
- ;__________________________________________________________________________________
-
- PRINT PUSH,OFF
- INCLUDE 'SysEqu.a' ; System definitions
- INCLUDE 'SysErr.a' ; System errors
- INCLUDE 'ToolEqu.a' ; Toolbox definitions
- INCLUDE 'Traps.a' ; Traps definitions
- INCLUDE 'LAPEqu.a' ; LAP manager defs
- INCLUDE 'AURPEqu.a' ; AURP atlk definitions
- INCLUDE 'HardwareEqu.a' ; some hardware stuff
- INCLUDE 'Private.a' ; System private definitions
- PRINT POP
-
- EXPORT GETSYSMEM, GETMYA5, SETMYA5
-
- ;
- ; The main shell structure. Modify if necessary, but the variables
- ; provided should be sufficient.
- ;
- XTIvarsRec RECORD 0 ; MIRROR XTISHELL.H
- cGlobals DS.L 1 ; Ptr to variables used in C routine
- HopCntWght DS.W 1 ; ipt's hop count weight
- remoteAddr DS.B 16 ; remote DTE address as pascal string
- AURPWriteEntry DS.L 1 ; AURP LAP write code entry point
- AURPRefNum DS.L 1 ; AURP refnum
- NextIRBlk DS.L 1 ; next IR
- lineSpeed DS.L 1 ; faked line speed to tell the router
- AURPDispatch DS.L 1 ; aurp dispatch routine
- OurDI DS.W 1 ; our domain identifier
- otherNode DS.L 1 ; domain identifier
- maxRPktSz DS.W 1 ; maximum packet size
- wDSPtr DS.L 1 ; WDSPtr for XTIWRITE
- rcvBufAvail DS.B 1 ; set flag if receive buffer is available
- rcvPktsWaiting DS.B 1 ; flag will be set in C routine if data are outstanding
- XTIFlags DS.B 1 ; flags for this atlk
- OurPortId DS.B 1 ; Our port id
- OurSlotId DS.B 1 ; Our slot id , will be set in C routine
- XTIvarsize DS.B 0
- ENDR
-
- LWEnableSCC EQU 6 ; Don't disable SCC
-
- ; XTIFlags bits
- XTIInit EQU 0 ; bit 0, set if init'ed
- XTIClose EQU 1 ; bit 1, set if closing
- XTILapInst EQU 2 ; bit 2, set if LAP write code is installed
-
-
- ;________________________________________________
- ;
- ; Begin main atlk code
- ;
- ;________________________________________________
-
- XTISHELL MAIN EXPORT ; this entry point is the LAPWRITE hook
-
- IMPORT DOXTIINSTALL, DOXTIDISCONNECT, DOXTISHUTDOWN, XTICONNECT, XTIWRITE, READDONE
- EXPORT CONNDONE, GETGLOBALS
-
- WITH XTIVarsRec
- ;
- ; If the code is entered at this point, the LAP Manager is calling the adev
- ; to perform a write, so just branch to the LAPWrite code.
- ;
- BRA.S LAPWrite
- ;
- ; AURP is calling us. On entry D0 contains command code. Use the jump tables
- ; (ControlTable and XTICntrlTbl) to jump to appropriate routine. ControlTable
- ; has a base of D0 = 0, and XTICntrlTbl has a base of D0 = 32. This code should
- ; NOT need any modifications.
- ;
- XTIControl
- LINK A6,#0 ; allocate our local stack frame
- MOVEM.L A2-A3/D3-D4,-(SP) ; save these registers
- ; for all control calls.
- CMP.W #AInstall,D0 ; is it an install call?
- BNE.S @tryAGetIF ; branch if not
- @ProcReq
- MOVE.L D1,-(SP) ; save this reg.
- ADD.W D0,D0 ; D0 = D0 * 2;
- MOVE.W ControlTable(D0.W),D0 ; get the routine offset
- JSR ControlTable(D0.W) ; process the request
- BRA.S @XTICntrlDone
- @tryAGetIF
- MOVE.L ATLKVars,A3 ; A3 -> our variables
- CMP.W #AGetInfo,D0 ; is it a get info call?
- BEQ.S @ProcReq ; branch if so
- @tryShutDwn
- CMP.W #AShutdown,D0 ; is it a shutdown call?
- BEQ.S @ProcReq ; branch if so
-
- CMP.W #ATnlGetNextIR,D0 ; is it a NextIR req call?
- BEQ.S @ProcReq2 ; branch if so
-
- CMP.W #ATnlDisconnect,D0 ; is it a disconnect req call?
- BEQ.S @ProcReq2 ; branch if so
-
- CMP.W #ATnlConnect,D0 ; is it a connect call?
- BNE.S @ParamError ; branch if not
- @ProcReq2
- MOVE.L D1,-(SP) ; save this reg.
- SUB.W #ATnlConnect,D0 ; adjust call # for 2nd tbl
- ADD.W D0,D0 ; D0 = D0 * 2;
- MOVE.W XTICntrlTbl(D0.W),D0 ; get the routine offset
- JSR XTICntrlTbl(D0.W) ; process the request
- @XTICntrlDone
- MOVE.L (SP)+,D1 ; restore this one
- MOVEM.L (SP)+,A2-A3/D3-D4
- UNLK A6
- RTS
- @ParamError
- MOVEM.L (SP)+,A2-A3/D3-D4
- BSR.S ParamError
- UNLK A6
- RTS
-
- ;
- ; The LAP Manager wants us to write out a packet.
- ; Give it to AURP.
- ;
- LAPWrite:
- CMP.B #0,D0 ; Write pkt out?
-
- MOVE.L ATLKvars, A3
- MOVE.L XTIVarsRec.AURPRefNum(A3), D1
- MOVE.L XTIVarsRec.AURPWriteEntry(A3), A3
- JMP (A3)
-
- ;
- ; The control table for standard atlk calls made from AURP
- ;
- ControlTable
- DC.W ParamError-ControlTable ; D0 = 0 not supported
- DC.W DoInstall-ControlTable ; D0 = 1 AInstall Lap
- DC.W DoShutdownAtlk-ControlTable ; D0 = 2 AShutdown Lap
- DC.W DoGetInfo-ControlTable ; D0 = 3 AGetInfo
-
- ;
- ; The control table for AURP specific atlk calls made from AURP
- ; Note: D0 base is 32.
- ;
- XTICntrlTbl
- DC.W DoATlkConnect-XTICntrlTbl ; D0 = 0 ATnlConnect
- DC.W DoATnlDisconnect-XTICntrlTbl ; D0 = 1 ATnlDisconnect pkt
- DC.W GetNextIR-XTICntrlTbl ; D0 = 2 return next ir
-
- ParamError
- MOVEQ.L #-1,D0 ; Indicate failure
- RTS
-
- ;
- ; XTIShellVarsPtr GETGLOBALS (void)
- ;
- GetGlobals
- MOVE.L ATLKvars,D0
- RTS
-
- ATLKvars DC.L 0 ; a pointer to our vars
- UNLK A6
- RTS
-
-
- ;________________________________________________
- ;
- ; DoInstall
- ;
- ; This code performs the installation of the adev (AURP AInstall).
- ; Possible modifications to be made are the Domain Indicator and
- ; NextIRBlock returned to AURP, but should not be necessary except
- ; for point to point links.
- ;
- ; Call:
- ; D3.L = AURP LAP write code entry point
- ; D4.L = port number on which to perform the install operation
- ; A0.L -> AURP Interface Dispatch Routine
- ; A1 -> pointer to ATnlConfig parameter block
- ; A2 = AURP Refnum
- ;
- ; Return:
- ; D0.W = error code (non zero indicates an error)
- ; A1 -> pointer to ATnlConfig parameter block
- ;
- ;________________________________________________
-
- InstallErr
- MOVEM.L (SP)+,A0-A1 ; clean up stack
- BRA CloseADEV ; and close
- Install2Err
- MOVE.L ATLKvars, A0
- _DisposPtr ; dispose of the ATLKvars
- MOVEM.L (SP)+, A0-A1 ; clean up stack
- BRA CloseADEV ; and close
- Install3Err
- MOVE.L ATLKvars, A0
- _DisposPtr ; dispose of the ATLKvars
- MOVE.L NextIRBlk(A3), A0
- _DisposPtr ; dispose of the NextIRBlk
- MOVEM.L (SP)+, A0-A1 ; clean up stack
- BRA CloseADEV ; and close
-
- DoInstall ; initialization
-
- MOVEM.L A0-A1,-(SP) ; save off rtmi ptr and port info pb
- MOVE.L #XTIvarsize,D0 ; size of our vars
- _NewPtr ,SYS,CLEAR ; get some memory
- BNE.S InstallErr ; no can do
- LEA ATLKvars,A3
- MOVE.L A0,(A3) ; save vars ptr
- MOVE.L A0,A3 ; A3-> our vars
- MOVE.L D3, AURPWriteEntry(A3) ; save the write entry code pointer
- MOVE.L A2, AURPRefNum(A3) ; save the AURP vars
- MOVE.L #6, D0
- _NewPtr ,SYS,CLEAR ; get some memory
- BNE.S Install2Err
- MOVE.L A0, XTIVarsRec.NextIRBlk(A3) ; save the next IR blk value
- MOVE.B D4,OurPortId(A3) ; save our port number
-
- MOVEM.L (SP),A0-A1 ; restore A0 & A1 = port info pb
- MOVE.L A1, A2 ; move the port info pointer into A2
- MOVE.L A0,AURPDispatch(A3) ; save aurp dispatch routine
- MOVE.W ATnlCfgPBlk.HopCntWgt(A2),D0 ; save hopcount weight
- MOVE.W D0, HopCntWght(A3)
- MOVE.L ATnlCfgPBlk.PaidPtr(A2),A0 ; A0 -> paid ptr (src ptr)
- ADDQ.L #2, A0 ; skip length
- MOVE.L A0, -(SP) ; move paid ptr onto stack
- MOVE.L ATnlCfgPBlk.ACfgPtr(A2),A0 ; A0 -> acfg ptr (src ptr)
- MOVE.L A0, -(SP) ; move acfg ptr onto stack
- MOVE.L A3, -(SP) ; move varsPtr onto stack
- JSR DOXTIINSTALL ; call C routine
- ADDA #12, SP
- TST.W D0
- BNE.S Install3Err ; no can do
-
- MOVEM.L (SP)+,A0-A1 ; restore A0 & A1 = port info pb
- MOVE.L A1, A2 ; move the port info pointer into A2
- ;
- ; Insert atlk's LAP write code
- ;
- @InsertLW MOVEA.L LAPMgrPtr,A1 ; A1->LAPmgr
- MOVEQ #LWrtInsert,D0 ; func code
- LEA XTISHELL,A0 ; A0->us
- CLR.B D1
- CLR.W D2 ; try ENQ's forever maybe
- BSET #LWEnableSCC,D1 ; don't disable SCC when calling us
- JSR LAPMgrCall(A1) ; install ourself as new LAPWrite
- BSET #XTILapInst, XTIFlags(A3) ; set flag that LAP write code is installed
-
- ;
- ; Setup the ATnlPBlk entries to give to AURP
- ; A2 still equals the pointer to ATnlConfigPB
- ;
- MOVE.L #0, D2
- MOVE.W maxRPktSz(A3), D2 ; D2 = max packet size
- MOVE.W D2, ATnlCfgPBlk.maxRPktSz(A2) ; D2 needs to be size of Packet
- MOVEQ #0, D1 ; D1 = kRtr flags
- BSET.L #ConfigLstOnly, D1 ; use only our list of one
- MOVE.L D1, ATnlCfgPBlk.atlkFlags(A2) ; set up the router host flags
- LEA DoXTIWrite, A0
- MOVE.L A0, ATnlCfgPBlk.atlkWriteCode(A2) ; setup the write code
- LEA FreeReadBuf, A0
- MOVE.L A0, ATnlCfgPBlk.atlkReadDone(A2) ; setup the read done code
- MOVE.W #1, ATnlCfgPBlk.numNextIRs(A2) ; setup num next IRs
- MOVE.B #1, ATnlCfgPBlk.srcDILen(A2) ; set up our srcDI length
- ;
- ; The domain indicator for a point to point link is set to 1. This indicator
- ; is more relevant for multipoint links for routers to distinguish who the
- ; information is coming from. On point to point links, there is only one other
- ; router the data could be coming from.
- ;
- LEA XTIVarsRec.OurDI(A3), A1 ; save ourDI
- MOVE.W #$0100, (A1) ; this is the null DI
- ;
- ; The otherNode variable is set in XTIShell.c to a value indicating that
- ; the other (next) router (in this case the other end of the point to point
- ; link) is answering or calling. This information is used in a multipoint link
- ; when AURP indicates a write is to be made to know which router to write to.
- ; However, with a point to point link, there is only one router to write to,
- ; making nextIR irrelevant.
- ;
- MOVE.L XTIVarsRec.NextIRBlk(A3),A0 ; get the next IR blk value
- MOVE.W #1, (A0) ; save length = 1
- MOVE.L otherNode(A3), 2(A0) ; save other nir
- MOVE.L A0, -(SP) ; next ir block ptr
-
- PEA XTIVarsRec.OurDI(A3) ; our address
- MOVE.L XTIVarsRec.AURPRefNum(A3), -(SP) ; the aurp vars
- MOVE.L #kAURPInstallDone, -(SP) ; csCode = AURPInstallDone
- MOVE.L XTIVarsRec.AURPDispatch(A3), A0 ; the dispatch rtn
- JSR (A0) ; call it
- ADDA #16, SP ;
- CLR.W D0 ; set return code for caller
- RTS
-
- ;________________________________________________
- ;
- ; DoGetInfo
- ;
- ; This code performs the AURP AGetInfo call to get information
- ; about the adev. Possible modification would be to the link
- ; address (probably not). Since most of the variables are set
- ; in the C routines, this code is probably ok.
- ;
- ; Call:
- ; D1.W = length of reply buffer
- ; A1.L -> reply buffer
- ;
- ;
- ; Return: A1.L -> reply buffer
- ; D0.W = Result code
- ;________________________________________________
-
- WITH ATlkInfo
-
- DoGetInfo:
- CMP.W #AInfoSz,D1 ; buffer big enough?
- BLT.S @Error ; no
-
- MOVE.L ATLKvars,D3 ; has this atlk been installed?
- BEQ.S @Error ; no
-
- MOVE.L D3,A3 ; A3 -> our vars
- MOVE.L A1,A2 ;
- MOVE.W #AInfoVers,Version(A2) ; version (of atlk)
- MOVE.W #AInfoSz,InfoLength(A2) ; number of bytes returned
-
- BTST.B #XTIInit, XTIFlags(A3) ; see if we've inited
- BNE.S @initInfo ; if so, give real values
- MOVE.L lineSpeed(A3),LinkSpeed(A2) ; the line speed
- CLR.B BandWidth(A2) ; bandwidth (weight factor)
- BRA.S @contInfo
-
- @initInfo MOVE.B HopCntWght+1(A3),Bandwidth(A2) ; link weight (value returned from AURP + 1)
- @contInfo CLR.B Reserved(A2) ; reserved (must be zero)
- CLR.W Reserved+1(A2)
- MOVE.B OurSlotId(A3), Reserved+1(A2) ; "slot number" in second reserved byte for SNMP
- MOVEQ #0,D0 ; flags
- BSET #AtlkExtended,D0 ; extended port
- MOVE.B D0,Flags(A2)
-
- MOVE.B #0,LinkAdrLen(A2) ; no relevant addr
-
- MOVEQ #noErr,D0
- RTS ; return success
- @Error
- MOVEQ #-1,D0 ; return error
- RTS
- ;________________________________________________
- ;
- ; DoAtlkConnect
- ;
- ; This code performs the AURP ATnlConnect call. The guts of the call
- ; are performed in the C routine XTICONNECT. Should NOT need to be
- ; modified.
- ;
- ; No parameters sent in.
- ;
- ; Return: D0.W = Result code
- ;________________________________________________
-
- DoAtlkConnect
- MOVE.L ATLKvars, A3
- BCLR #XTIClose, XTIFlags(A3) ; connection no longer closed
- MOVE.L A3, -(SP) ; pass our vars
- JSR XTICONNECT ; call C routine to start connection
- ADDQ.L #4,SP ; restore stack
- TST.W D0
- BNE CloseADEV
-
-
- RTS
- ;__________________________________________
- ;
- ; ConnDone (long errResult);
- ;
- ; This routine is called from several C routines to indicate that
- ; a connection is complete, a connection could not be established,
- ; or a connection has gone down unexpectedly. AURPTnlConnDone is
- ; called with noErr or with an error (latter two cases). If it is
- ; called with an error, the port will be made inactive. Should
- ; NOT need to be modified.
- ;
- ;__________________________________________
-
- CONNDONE
- MOVE.L A3, -(SP) ; save A3
- MOVE.L ATLKvars, A3 ; get our vars
- MOVE.L 8(A7), D0 ; see if connection good
- BNE.S @ConnErr ; if not, error
- BSET #XTIInit, XTIFlags(A3) ; set flag that init done
-
- MOVE.L #0, -(SP) ; the connection result
- MOVE.L AURPRefNum(A3), -(SP) ; pass the vars
- MOVE.L #kAURPTnlConnDone, -(SP) ; cmdType = TnlConnection Done
- MOVE.L AURPDispatch(A3), A3 ;
- JSR (A3) ; make the call
- ADDA #12, SP
- MOVE.L (SP)+, A3
- RTS
-
- @ConnErr MOVE.L ATLKvars, A3
- BTST #XTIClose, XTIFlags(A3) ; see if closing
- BNE.S @ConnEx
- MOVE.W #-1, D0
- MOVE.L D0, -(SP) ; the connection result
- MOVE.L AURPRefNum(A3), -(SP) ; pass the vars
- MOVE.L #kAURPTnlConnDone, -(SP) ; cmdType = TnlConnection Done
- MOVE.L AURPDispatch(A3), A3 ;
- JSR (A3) ; make the call
- ADDA #12, SP
- @ConnEx MOVE.L (SP)+, A3 ; restore A3
- RTS
-
- ;__________________________________________
- ;
- ; GetNextIR
- ;
- ; Performs the AURP ATnlGetNextIR call. Returns the
- ; address of the other router. The next IR reference
- ; indicator is not looked at because this is a point
- ; to point implementation and there is only one
- ; next IR. If you have used the remoteAddr field, this
- ; code should NOT need to be modified. May want to tailor
- ; the string based on whether the router is active or
- ; passive on connect. For example, DialUp, returns "Answering"
- ; if the router is in answer mode.
- ;
- ; Call: D1 = next ir ref indicator
- ; A1 -> next ir string ptr (up to 16 bytes)
- ;
- ;
- ; Return: A1 -> next IR String
- ; D0.L = error code
- ;
- ;__________________________________________
-
- NIRStrMax EQU 32
-
- GetNextIR
- MOVEQ #0, D0 ; clear out D0
- MOVE.L #-1,D3 ; assume error
- MOVE.L ATLKvars, A3 ; get the globals pointer
- BTST.B #XTIInit, XTIFlags(A3) ; make sure init'd
- BEQ.S @GetNxtIRErr ; error if not
- CMP.B #NIRStrMax-1, remoteAddr(A3) ; see if less than max
- BLS.S @getStrLen
- MOVE.B #NIRStrMax-1, D0 ; if greater than max, length byte is max - 1
- BRA.S @copyStr
- @getStrLen MOVE.B remoteAddr(A3), D0 ; actual length
- @copyStr MOVE.B D0, (A1)+ ; length byte
- LEA remoteAddr+1(A3), A0 ; A0 = ptr to remote addr (src)
-
- _BlockMove
- MOVEQ #0,D3 ; set result code to no err
-
- @GetNxtIRErr
- MOVE.L D3,D0 ; move result to D0
- RTS
-
- ;__________________________________________
- ;
- ; DoATnlDisconnect
- ;
- ; Performs the AURP ATnlDisconnect call. Main code is in C routine
- ; DoXTIDisconnect. This code should NOT need to be modified.
- ;
- ; Call: A3.L -> our vars
- ;
- ; Return: D0.L = error code
- ;
- ;__________________________________________
-
- DoATnlDisconnect
- MOVE.L ATLKvars, A3 ; get the globals pointer
- BSET #XTIClose, XTIFlags(A3) ; set flag for closing...
- MOVE.L A3, -(SP)
- JSR DOXTIDISCONNECT ; Call C routine
- ADDQ.L #4, SP
- BCLR #XTIInit, XTIFlags(A3) ; no longer inited...
- MOVE.L D0, -(SP) ; the disconnect result
- MOVE.L AURPRefNum(A3), -(SP) ; the refnum
- CLR.L D0
- MOVE.B #kAURPTnlDiscDone, D0 ; csCode = AURPTnlDiscDone
- MOVE.L D0, -(SP)
- MOVE.L AURPDispatch(A3), A0
- JSR (A0) ; make the call
- ADDA #12, SP
- CLR.L D0 ; the disconnect result
- RTS
- ;_____________________________________________
- ;
- ; DoShutdownAtlk
- ;
- ; Performs the AURP AShutdown call.
- ;
- ; Call: D4.B = port number on which to perform the shutdown
- ;
- ; Return: D0 = error code
- ;
- ;_____________________________________________
-
- DoShutdownAtlk
- MOVEQ #0,D0 ; no init error has occurred
- ; shut down normally
-
- ;_____________________________________________
- ;
- ; CloseADEV
- ;
- ; Complete shutdown. Also called when an error occurs during
- ; installation or when connecting. This code should NOT need
- ; to be modified.
- ;
- ; Return: D0.L = error code
- ;
- ;_____________________________________________
-
- CloseADEV
- MOVE.L D0,D3 ; save error code
- MOVE.L ATLKvars,D0 ; do we have our vars?
- BEQ.S DoneClose
-
- MOVE.L D0,A3 ; A3 -> our vars
- BTST #XTIInit, XTIFlags(A3) ; see if we've been inited
- BEQ.S @SkipClose ; if not, skip close of endpoint
- JSR DoATnlDisconnect
- BRA.S @ContClose ; br to dispose memory
-
- @SkipClose
- BSET #XTIClose, XTIFlags(A3) ; set flag for closing...
- @ContClose
- BSR.S DeAllocMem
-
- MOVE.W D3,D0 ; pass the error code
- RTS
-
- DeAllocMem
- MOVE.L A3, -(SP)
- JSR DOXTISHUTDOWN ; call C routine to dispose memory
- ADDQ.L #4, SP
-
- BTST.B #XTILapInst, XTIFlags(A3) ; see if LAP write code is installed
- BEQ.S @NoLAPMgr
- MOVEM.L D4,-(SP) ; save D4
- MOVE.B OurPortId(A3),D4 ; D4 = our port id
- MOVE.L LAPMgrPtr,A1 ; A1 -> LAP manager
- MOVEQ #LWrtRemove,D0 ; function code
- JSR LAPMgrCall(A1) ; call the LAP manager to remove us
- MOVEM.L (SP)+,D4 ; restore D4
-
- @NoLAPMgr
- MOVE.L A3,A0 ; A0 -> our variables
- _DisposPtr ; get rid of them
- MOVE.L NextIRBlk(A3), A0
- _DisposPtr ; dispose of the NextIRBlk
- LEA ATLKvars,A0
- CLR.L (A0) ; clear vars ptr
-
- DoneClose
- RTS ; That's it (CDEV will dispose us)
-
-
-
- ; ___________________________________________
- ;
- ; FreeReadBuf
- ;
- ; Routine called after route receive completes (ATnlReadDone).
- ; Set the flag indicating the receive buffer is free, then
- ; check to see if there are packets waiting to be read. If
- ; there are, go read them. This code should NOT need to be
- ; modified unless the read packet scheme is modified.
- ;
- ; ___________________________________________
-
- FreeReadBuf
- IMPORT RESTORESR
-
- JSR RESTORESR ; restore interrupt level
- MOVE.L ATLKvars, A0 ; A0 -> our vars;
- MOVE.B #1, rcvBufAvail(A0) ; set rcvBufAvail boolean
- MOVEQ #0,D0
- MOVE.B rcvPktsWaiting(A0), D0
- TST.W D0 ; if there are no packets waiting to be read
- BEQ.S @FreeDone ; we are done
- MOVE.L A0, -(SP) ; pass our vars
- JSR READDONE ; call C routine to read packets
- ADDQ.L #4,SP ; restore stack
-
- @FreeDone
- RTS
-
-
-
- ; ___________________________________________
- ;
- ; DoXTIWrite (NIRIndicator dstNextIR, WDSElement *wdsPtr)
- ;
- ; Performs the AURP ATnlDoWrite call. Send the
- ; packet out on the wire. If an error occurs, call AURPWriteDone
- ; with an error. Otherwise, it will be called when the T_SendComplete
- ; event is received. This code should NOT need to be modified.
- ;
- ; Call:
- ;
- ; ___________________________________________
-
- DoXTIWrite
-
- MOVE.L ATLKvars, A3
- MOVE.L 8(SP), wDSPtr(A3) ; wDSPtr -> send buffer
- MOVE.L A3, -(SP) ; pass our vars
- JSR XTIWRITE ; call C routine to start connection
- ADDQ.L #4,SP ; restore stack
- TST.W D0
- BNE.S @WriteErr
- RTS
-
- @WriteErr MOVE.L D0,-(SP) ; the writeResult
- CLR.L D0
- MOVE.L ATLKvars,A1
- MOVE.L wDSPtr(A1), -(SP) ; the wdsptr
- MOVE.L XTIVarsRec.AURPRefNum(A1),-(SP) ; AURP vars
- MOVE.L #kAURPWriteDone, -(SP) ; the cmd type
- MOVE.L XTIVarsRec.AURPDispatch(A1), A0
- JSR (A0) ; call write done with an error
- ADDA #16, SP
- RTS
-
- ;________________________________________________
- ;
- ; GETSYSMEM (long sizeNeeded);
- ;
- ; Allocates specified amount of memory in the system heap.
- ; This code should NOT need to be modified.
- ;
- ;________________________________________________
-
- GETSYSMEM PROC
- MOVE.L 4(A7), D0 ; get amount to alloc
- _NewPtr ,SYS,CLEAR ; call memory mgr
- BNE.S @5 ; error
- MOVE.L A0, D0 ; otherwise, get pointer
- BRA.S @10
- @5 CLR.L D0 ; if err, D0=0
- @10 RTS ; return with pointer in D0
- ENDPROC
-
- ;________________________________________________
- ;
- ; GETMYA5, SETMYA5
- ;
- ; Get and set A5. Needed to get global variable AtlkVars
- ; from a routine called by the time manager. This code should
- ; NOT need to be modified.
- ;
- ;________________________________________________
-
- GETMYA5 PROC
- MOVE.L A5,D0
- RTS
- ENDPROC
-
- SETMYA5 PROC
- MOVE.L 4(A7), A5
- RTS
- ENDPROC
-
- ;________________________________________________
- ;
- ; GETSR, RESTORESR
- ;
- ; Set and Restore the interrupt level. Needed because
- ; the router sets the interrupt level to VSCCEnable
- ; on completion of a read call.
- ;
- ;________________________________________________
-
-
- GETSR PROC EXPORT
- EXPORT RESTORESR
- LEA SRX,A0 ; A0 -> SRX global
- MOVEQ #0,D0 ; clear D0
- MOVE SR,D0 ; put the status register into D0
- MOVE.L D0,(A0) ; save the status register
- RTS
-
- SRX DS.L 1
-
- RESTORESR MOVE.L SRX,D0 ; saved value into D0
- MOVEQ #0,D1
- MOVE SR,D1 ; current status register in D1
- ANDI #$0700,D1 ; and with 0x07 to get interrupt level
- ANDI #$0700,D0 ; same with D0
- CMP.L D0,D1 ; if they aren't the same,
- BGE.S @restore ; go to restore the status
- RTS
-
- @restore MOVE.L SRX,D0 ; saved value in D0
- MOVE D0,SR ; saved value in status register
- RTS
- ENDPROC
- END
-
-